/*
 * @Description: 
 * @Author: zoe
 * @Date: 2024-10-09 19:38:39
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-09 20:01:27
 */
public class Test3_DivisionByZero {
    //division方法：执行10/0操作，抛出异常
    public void division() throws ArithmeticException{
        int result = 10/0;
        System.out.println("Result:" + result);
    }
    //main方法：调用division方法
    // public static void main(String[] args) {
    //     Test3_DivisionByZero test = new Test3_DivisionByZero();
    //     test.division();
    // }

   // main方法：调用division方法并处理抛出的异常
    public static void main(String[] args) {
        Test3_DivisionByZero test = new Test3_DivisionByZero();
        try {
            test.division();
        } catch (ArithmeticException e) {
            System.out.println("捕获到异常：" + e.getMessage());
        }
    }
}